<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('拖动排序')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
    <th:block th:include="include :: summernote-css"/>
    <!--<style>
        b {
            font-weight: bold;
            display: block;
            content: "";
            clear: both;
        }
    </style>-->
</head>
<body class="gray-bg">
<div class="ui-layout-west" style="width: 400px">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 功能总览
            </div>
            <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>
<div class="ui-layout-center">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 功能说明
            </div>
        </div>
        <div class="ui-layout-content">
            <img th:src="@{/img/功能概览2.png}" width="100%" height="80%" id="mainImg"/>
            <div class="summernote">
                <p id="munuIntro">
                </p>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />
<th:block th:include="include :: summernote-js"/>
<script>
    function getJobs(day) {
        $.ajax({
            url: '/monitor/jobLog/queryJobStatus?day='+day,
            type: 'get',
            dataType: 'json',
            success: function (result) {
                if(result.code==0) {
                    var html = "",statusDes,buttonHtml="";
                    $.each(result.data,function (index,item) {
                        statusDes = null;
                        if(item.sysJob.status=='1') { //未启用
                            html += '<li class="disabled-element" style="color: lightgrey">';
                            statusDes = "待启用";
                        } else if(item.fgError) {
                            html += '<li class="danger-element">';
                            buttonHtml = '<a href="#" class="pull-right btn btn-xs btn-danger">异常</a>';
                        } else {
                            html += '<li class="success-element">';
                            buttonHtml = '<a href="#" class="pull-right btn btn-xs btn-primary">正常</a>';
                        }
                        html += '<span style="font-weight:bold">'+item.sysJob.jobName+'['+(statusDes==null?item.groupVO.total:'待启用')+']</span>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '+item.sysJob.cronExpression;
                        html += '<div class="agile-detail">'+buttonHtml+'<i class="fa fa-clock-o"></i> 距离下次执行时间：'+item.dateDvalue+'</div></li>';
                    });
                    $("#mainUl").html(html);
                } else {
                    $.modal.alertError(result.msg);
                }
                $("#bootstrap-table").bootstrapTable('refresh');
            }
        });
    }
    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });

    function queryMenuTree()
    {
        var url = ctx + "system/menu/mainMenuTreeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);
        function zOnClick(event, treeId, treeNode) {
            let id=treeNode.id;
            $.ajax({
                url: "/system/menu/selectMenuById?menuId="+treeNode.id,
                cache: false,
                type: 'GET',
                dataType: 'json',
                success: function (result) {
                    $("#mainImg").remove();
                    debugger;
                    var intro = result.data.intro;
                    if(intro==null) {
                        $('.summernote').html("<p><b>功能分类：</b>"+treeNode.title+"</p>");
                    } else {
                        $('.summernote').html(intro);
                    }
                }
            });
        }
    }

    $(function() {
        $('.summernote').summernote('destroy');
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({ initClosed: panehHidden, west__size: 185 });
        // 回到顶部绑定
        if ($.fn.toTop !== undefined) {
            var opt = {
                win:$('.ui-layout-center'),
                doc:$('.ui-layout-center')
            };
            $('#scroll-up').toTop(opt);
        };
        queryMenuTree();
        /*let setting = {
            callback:{
                onclick:treeClick
            },
          data:{
              key:{
                  name:"name",
              },
              simpleData: {
                  enable: true,
                  idKey:"id",
                  pIdKey: "pId"
              }
          }
        };
        let zNodes=[
            {"name":"经管办","id":"01","pId":"01"},
            {"name":"全院医疗收入","id":"0101","pId":"01"},
            {"name":"门诊医疗收入","id":"0102","pId":"01"},
            {"name":"住院医疗收入","id":"0103","pId":"01"},
            {"name":"财务科","id":"02","pId":"02"},
            {"name":"财务门诊收入","id":"0201","pId":"02"},
            {"name":"财务住院收入","id":"0202","pId":"02"},
            {"name":"财务精品中药收入","id":"0203","pId":"02"},
        ];
        var ZTreeObj = $.fn.zTree.init($("#tree"), setting, zNodes);
        ZTreeObj.expandAll(true);

        function treeClick(event, treeId, treeNode) {
            alert("click");
        }*/
        /*var day = dateFormat(null);
        $("#dtSysCre").val(day);
        getJobs(day);
        var options = {
            url: "/system/msg/list",
            modalName: "消息中心",
            columns: [{
                checkbox: true
            },
                {
                    field: 'idMsg',
                    title: '',
                    visible: false
                },
                {
                    field: 'cont',
                    title: '内容'
                },
                {
                    field: 'dtSysCre',
                    title: '时间'
                }]
        };
        $.table.init(options);*/
    });
</script>
</body>
</html>
